﻿using System;
using System.Collections.Generic;
using System.IO.IsolatedStorage;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BudgetManager.Utils
{
    public class AppSettingsHelper
    {
        /// <summary>
        /// Removes the key-value pair fron appsettings
        /// </summary>
        /// <param name="appSettingsKey">key with which data is stored</param>
        public static void removeAppSettings(string appSettingsKey)
        {
            if (IsolatedStorageSettings.ApplicationSettings.Contains(appSettingsKey))
            {
                IsolatedStorageSettings.ApplicationSettings.Remove(appSettingsKey);
            }
            IsolatedStorageSettings.ApplicationSettings.Save();
        }

        /// <summary>
        /// Updates/Creates a new appsettings entry
        /// </summary>
        /// <param name="AppsettingsKey">key with which data is(is to be) stored</param>
        /// <param name="value"></param>
        public static void saveAppSettings(string AppsettingsKey, object value)
        {
            if (IsolatedStorageSettings.ApplicationSettings.Contains(AppsettingsKey))
            {
                IsolatedStorageSettings.ApplicationSettings[AppsettingsKey] = value;
            }
            else
            {
                IsolatedStorageSettings.ApplicationSettings.Add(AppsettingsKey, value);
            }
            IsolatedStorageSettings.ApplicationSettings.Save();
        }
    }
}
